package com.molyfun.parents.activity.classroom;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.molyfun.parents.R;
import com.molyfun.parents.activity.common.BaseActivity;
import com.molyfun.parents.rest.bean.AnnouncementListResponse;
import com.molyfun.parents.utils.StringUtils;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by william(liuchao.hit@gmail.com).
 * Date:11/2/16.
 * 家庭作业详情页接口
 */
public class AnnouncementDetailActivity extends BaseActivity implements View.OnClickListener{

    private static final String FLAG_ANNOUNCEMENT_BEAN = "announcement_bean";

    @InjectView(R.id.base_title_left)
    ImageView mBackBtn;
    @InjectView(R.id.base_title)
    TextView mTitle;

    @InjectView(R.id.announcement_content)
    TextView mAnnouncementContent;
    @InjectView(R.id.user)
    TextView mUser;
    @InjectView(R.id.time)
    TextView mTime;

    private AnnouncementListResponse.AnnouncementBean mAnnouncementBean;

    public static void startActivity(Context content, AnnouncementListResponse.AnnouncementBean announcementBean){
        Intent intent = new Intent();
        intent.setClass(content, AnnouncementDetailActivity.class);
        intent.putExtra(FLAG_ANNOUNCEMENT_BEAN, announcementBean);
        content.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_announcement_detail);

        ButterKnife.inject(this);
        getSupportActionBar().setTitle("");

        mTitle.setText("公告详情");
        mBackBtn.setOnClickListener(this);

        mAnnouncementBean = getIntent().getParcelableExtra(FLAG_ANNOUNCEMENT_BEAN);
        if(mAnnouncementBean == null){
            toast("公告数据为空");
            finish();
        }
        mTitle.setText(mAnnouncementBean.getTitle());
        mAnnouncementContent.setText(mAnnouncementBean.getNotice());
        mUser.setText("发布人:" + mAnnouncementBean.getUsername());
        mTime.setText("时间:" + StringUtils.formatDate(mAnnouncementBean.getCreatedatetime()));
    }



    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.base_title_left:
                finish();
                break;
        }
    }


}
